Skip to content

Send Aspire telemetry to Grafana as well, when asked to - #1121

Open
KrzysztofPajak wants to merge 1 commit into
developfrom
feature/aspire-grafana
Open

KrzysztofPajak wants to merge 1 commit into
developfrom
feature/aspire-grafana

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: feature

Issue

GrandNode already exports traces, metrics and logs through OpenTelemetry (Aspire.ServiceDefaults), and an installation can point them at any OTLP backend. Locally, though, the Aspire AppHost shows them only in its own dashboard: it sets each app's OTEL_EXPORTER_OTLP_ENDPOINT to the dashboard, and an exporter takes one endpoint only. There was no way to try the usual production setup - OpenTelemetry Collector in front of Grafana - without building it by hand.

Solution

A switch in the AppHost, Observability:Grafana (default false). When it is on, the AppHost also starts:

  • grafana/otel-lgtm 0.40.0 - Grafana with Tempo, Prometheus and Loki in one container, persistent, data in the grandnode-grafana volume;
  • an OpenTelemetry Collector (contrib 0.165.0) via CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector (MIT). WithAppForwarding() points the apps at the collector instead of the dashboard, and otel-collector.yaml sends every signal on to both the dashboard and Grafana.

The apps are not changed - their existing OTLP exporter does the work. The section "Telemetry in Grafana" in docs/development.md explains the switch; it is appended at the end of the file so it does not collide with #1120.

Breaking changes

None. The switch is off by default, so a plain AppHost run starts exactly what it did before.

Testing

  1. With Docker running, start the AppHost with the switch on: Observability__Grafana=true dotnet run --project src/Aspire/Aspire.AppHost --launch-profile https.
  2. The dashboard lists grafana and otel-collector; both become healthy before the grand-web replicas start.
  3. Open a page of either grand-web replica a few times.
  4. Open the grafana resource's URL: Explore → Tempo shows GET traces of grand-web, Loki shows its logs (service_name="grand-web"), Prometheus has the grandnode/grand-web job.
  5. The Aspire dashboard still shows the same traces, logs and metrics, and otel-collector's console has no "Exporting failed" lines.
  6. Start the AppHost without the variable: no grafana or otel-collector resource appears.

The Aspire AppHost points every app's OTLP exporter at its dashboard, and an
exporter takes one endpoint only. With Observability:Grafana set, the AppHost
starts an OpenTelemetry Collector in that place, which sends traces, metrics
and logs on to both the dashboard and a grafana/otel-lgtm container (Tempo,
Prometheus, Loki, Grafana). Off by default, so a plain run pulls nothing more.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

//an app exports to one OTLP endpoint only, which Aspire points at its dashboard - the collector takes
//that place and sends everything on to both the dashboard and Grafana
builder.AddOpenTelemetryCollector("otel-collector", settings => settings.CollectorTag = "0.165.0")
.WithConfig(Path.Combine(builder.AppHostDirectory, "otel-collector.yaml"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants